package impl;

import anaydis.sort.SorterType;

import java.util.Comparator;
import java.util.List;


public class SelectionSorter extends AbstractSorter{

    public <T> void sort(Comparator<T> tComparator, List<T> ts) {
        int N = ts.size();
        for (int i = 0; i < N; i++)
        {
            int min = i;
            for (int j = i+1; j < N; j++){
                if (greater(tComparator, ts, min, j)){
                    min = j;
                }
            }
            if(i!=min){
                swap(ts, i, min);
            }
        }
    }

    public SelectionSorter() {
        super(SorterType.SELECTION);
    }
}
